import redis


class MyRedis:
    def __init__(self):
        self.pool = redis.ConnectionPool()
        self.r = redis.Redis(connection_pool=self.pool)

    # str 存
    def set_str(self, key, v, time=0):
        if time > 0:
            self.r.setex(key, time, v)
        else:
            self.r.set(key, v)

    def get_str(self, key):
        return self.r.get(key)

myredis = MyRedis()